// $Id: PluginInfoCollection.cs 64 2008-05-06 18:29:47Z nvivo $

using System;
using System.Collections.Generic;
using System.Text;

namespace DBLGen
{
    public class PluginInfoCollection : List<PluginInfo>
    {
        public int IndexOfPlugin(Type type)
        {
            string qualifiedName = type.AssemblyQualifiedName;

            for (int i = 0; i < this.Count; i++)
                if (this[i].PluginType.AssemblyQualifiedName == qualifiedName)
                    return i;

            return -1;
        }

        public bool ContainsPlugin(Type type)
        {
            return IndexOfPlugin(type) > -1;
        }

        public PluginInfo[] SelectByBaseType(Type baseType)
        {
            List<PluginInfo> list = new List<PluginInfo>();

            foreach (PluginInfo pi in this)
                if (pi.BaseType == baseType)
                    list.Add(pi);

            return list.ToArray();
        }
    }
}
